home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / freeli22.zip / PROGS / GRTEST.ASM < prev    next >
Assembly Source File  |  1996-09-01  |  4KB  |  141 lines

  1. ; Graphics demo using FREELIB
  2.  
  3. Ideal
  4.  
  5. Public      main
  6. Extrn       startup:near
  7.  
  8. Macro       lcall p,a,b,c,d,e,f,g,h ;; library call
  9.  
  10.             ifnb <a>
  11.               push a                ;; if args, push first arg
  12.               lcall p,b,c,d,e,f,g,h ;; and recurse . . .
  13.             else
  14.               extrn p:near          ;; declare procedure
  15.               call p                ;; call procedure
  16.             endif
  17.  
  18. EndM
  19.  
  20. Macro       lnk offs                ;; Loop if No Key
  21.  
  22.             mov ah,1
  23.             int 16h
  24.             jz offs
  25.             xor ah,ah
  26.             int 16h
  27. EndM
  28.  
  29. Model Tiny
  30. Codeseg
  31. P186
  32. Org 100h
  33.  
  34. Start:      jmp startup
  35.  
  36. ;****************** Data Section
  37.  
  38. Str1        db 'This is a string . . .',0
  39.  
  40. WidthX      dw 320                  ;Variables
  41. Height      dw 200
  42. Colors      dw 256
  43. Circ        dw 30
  44.  
  45. ;****************** 'main' procedure
  46.  
  47. Proc        main
  48.  
  49.             lcall initgraph 0       ;Init lo-res mode
  50.             lcall srand             ;Seed random numbers
  51.             call loop1              ;Do the loops
  52.             mov [Height],400        ;Set med-res values
  53.             mov [Circ],60
  54.             lcall initgraph 2       ;Init med-res mode
  55.             call loop1              ;Do the loops
  56.             mov [WidthX],640        ;Set hi-res values
  57.             mov [Height],480
  58.             mov [Colors],16
  59.             mov [Circ],72
  60.             lcall initgraph 1       ;Init hi-res mode
  61.             call loop1              ;Do the loops
  62.             lcall closegraph        ;Close graphics
  63.             ret                     ;Return
  64.  
  65. ;****************** Main Loops
  66.  
  67. loop1:      call do_rand            ;Pixels
  68.             lcall putpix ax,bx
  69.             lnk loop1
  70.             lcall cls
  71.  
  72. loop2:      call do_rand            ;Lines
  73.             lcall line ax,bx,cx,dx
  74.             lnk loop2
  75.             lcall cls
  76.  
  77. loop3:      call do_rand            ;Rectangles
  78.             lcall rect ax,bx,cx,dx
  79.             lnk loop3
  80.             lcall cls
  81.  
  82. loop4:      call do_rand            ;Filled Rectangles
  83.             lcall frect ax,bx,cx,dx
  84.             lnk loop4
  85.             lcall cls
  86.  
  87. loop5:      call do_rand            ;Circles
  88.             lcall circle ax,bx,si
  89.             lnk loop5
  90.             lcall cls
  91.  
  92. loop6:      call do_rand            ;Ellipses
  93.             lcall ellipse ax,bx,si,di
  94.             lnk loop6
  95.             lcall cls
  96.  
  97. loop7:      call do_rand            ;Filled Circles
  98.             lcall fcircle ax,bx,si
  99.             lnk loop7
  100.             lcall cls
  101.  
  102. loop8:      call do_rand            ;Filled Ellipses
  103.             lcall fellipse ax,bx,si,di
  104.             lnk loop8
  105.             lcall cls
  106.  
  107. loop9:      call do_rand            ;Triangles
  108.             push ax bx cx dx
  109.             call do_rand
  110.             lcall triangle ax,bx
  111.             lnk loop9
  112.             lcall cls
  113.  
  114. loop10:     call do_rand            ;Strings
  115.             sub ax,88
  116.             lcall outstr ax,bx,offset(Str1)
  117.             lnk loop10
  118.             lcall cls
  119.             ret
  120.  
  121. ;****************** Get Random Numbers
  122.  
  123. do_rand:    lcall rand [Colors]     ;Set random color and get
  124.             lcall setgcolor ax      ;random numbers in AX, BX,
  125.             lcall rand [Circ]       ;CX, DX, SI, and DI.
  126.             mov di,ax
  127.             lcall rand [Circ]
  128.             mov si,ax
  129.             lcall rand [Height]
  130.             mov dx,ax
  131.             lcall rand [Height]
  132.             mov bx,ax
  133.             lcall rand [WidthX]
  134.             mov cx,ax
  135.             lcall rand [WidthX]
  136.             ret
  137.  
  138. EndP        main
  139.  
  140. End Start
  141.